<%--
    Document   : members
    Created on : 05.Haz.2011, 14:47:21
    Author     : Ahm
--%>

<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"  import="java.sql.*"%>
<jsp:useBean id="user" class="controls.UseBean" scope="session"/>
<jsp:useBean id="yazi" class="controls.UseBilgiBean" scope="session"/>
<%
controls.addinfo nesne = new controls.addinfo();
            int id = 0;
            boolean GenelBakis = false;
            ArrayList<String> memberlist = new ArrayList<String>();
            boolean arama = false;
            String arama1 = request.getParameter("ara");
            arama1 = arama1 + " ";
            if (arama1.equals(" ") || arama1.charAt(0) == ('n')) {
                arama = false;
            } else {
                arama = true;
                memberlist = nesne.memberarama(arama1.substring(0, arama1.length() - 1));

            }


            boolean GirisKontrol = false;
            String id1 = request.getParameter("id");
            id1 = id1 + " ";
            if (id1.equals(" ") || id1.charAt(0) == ('n')) {
//eğer bu if'e girerse members sayfasındaki tüm üyelere genel olarak bakmak için girmiştir
                GenelBakis = true;
            } else {
                //Burada id'si id'de kayıtlı olan üyenin hesabına bakmak için girildiği anlaşılıyor
                id = Integer.parseInt(id1.substring(0, id1.length() - 1));
                GenelBakis = false;
            }
            if (user.GetUserName().equals(" ")) {
                GirisKontrol = false;
            }
            try {
                controls.SQLConnection sqlconnect = new controls.SQLConnection();
                Statement komut = sqlconnect.GetUserTableConnection();
                Statement komut2 = sqlconnect.GetProfilTableConnection();


%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css" href="style.css" />
    <link rel="shortcut icon" href="images/icon.ico" />
    <title>JSP Page</title>
</head>

<body>
<div>
    <a href="index.jsp" class="logo"><img src="images/logo2.png" alt="" width="262" height="69" /></a>																										<div style="position:absolute;top:1px;left:1px;height:0px;width:0px;overflow:hidden"><h1><a href="http://www.freetemplatesonline.com">free web templates</a></h1><h1><a href="http://www.webdesign.org">web design</a></h1></div>
    <p class="links"><a href="help.jsp">Yardım</a> | <a href="help.jsp">SSS</a></p>
    <ul id="menu">
        <li><a href="index.jsp"><img src="images/but1.gif" alt="" width="109" height="48" /></a></li>
        <li><a href="about.jsp"><img src="images/but2.gif" alt="" width="109" height="48" /></a></li>
        <li><a href="Discoussion.jsp"><img src="images/but3.gif" alt="" width="109" height="48" /></a></li>
        <li><a href="members.jsp"><img src="images/but4.gif" alt="" width="109" height="48" /></a></li>
        <li><a href="articles.jsp"><img src="images/but5.gif" alt="" width="109" height="48" /></a></li>
        <li><a href="contact.jsp"><img src="images/but6.gif" alt="" width="109" height="48" /></a></li>
    </ul>
    <div>
        <div class="block">
            <img src="images/title1.jpg" alt="" width="215" height="62" /><br />
            <p> <% out.println("<h4>" + yazi.Yazi1() + "</h4>");                                            %>  </p>
            <a href="#"><img src="images/more.gif" alt="" width="75" height="27" /></a>
        </div>
        <img src="images/banner<%=nesne.randomimagecount()%>.png" alt="" width="654" height="297" border="0" usemap="#Map" />
		  </div>
</div>
<div id="content">
    <div class="line">
        <div class="sidebar">

            <%


                                    if (user.GetUserName().equals(" ") || user.GetUserName().charAt(0) == 'n') {                                        %>

            <img src="images/title2.gif" alt="" width="238" height="57" /><br />
            <h4>Lütfen Üye Girişi Yapınız</h4>
            <form action="index.jsp">
                Kullanıcı adı: <input type="text" name="kadi" value="" length="40" />
                <br>
                Şifre:<font color="#FFFFFF">...............</font><input type="password" name="sifre" value="" /><br><input type="submit" name="giris" value="Giriş Yap" />
                <br>
                <br>
            </form><a href="register.jsp"><img src="images/uyeol.jpg" alt="" /></a>
            <input type ="button"
                   value = "Hazır Üye bilgileri Öğrenmek için Tıklayın"
                   onClick="alert('K.adı:admin  şifre:admin')" />

            <%} else {
                 out.println("<h2>Hoşgeldin <br>" + user.GetRealName() + " </h2> <br> <h3>Öğrenci Numaranız:" + user.GetSNumber() + "</h3> <br>");
            %>
            <a href="/profil.jsp"><img border="0" src="images/profil.png" ></a>
            <a href="/pm.jsp"><img border="0" src="images/message.png"></a>
            <a href="index.jsp?cikis=exitttt"><img border="0" src="images/cikis.png"></a>

            <%
                                }
            %>
        </div>
        
        <div class="list">
            <img src="images/title3.gif" alt="" width="654" height="45" /><br />
            <%

                                if (GenelBakis == true) {
                                    ResultSet sonucuser = komut.executeQuery("SELECT * FROM usertable");
                                    ResultSet sonucprofil = komut2.executeQuery("SELECT * FROM profiltable");
                String aranacakkelime= "Üye Ara";
                if(arama==true){
                    aranacakkelime=arama1.substring(0, arama1.length()-1);}
                                    %>

                <table border="1" width="100%">
                    <tr>
                        <td bgcolor="#FAF3E4"> <img src="images/mem1.png" alt="" /></td>
                    </tr>
                    <tr>
                        <td><form action="members.jsp">
                                <p align="center">    <input type="text" name="ara" value="<%=aranacakkelime%>" />
                                <input type="submit" value="Arama Yap" name="arama" />
                            </form></td>
                    </tr>


                    <%
                                                              if (arama == true) {
                                                                  for (int i = 0; i < memberlist.size(); i++) {

                                                  %>
                    <tr>
                        <td bgcolor="#FAF3E4">
                            <h3> <a href="members.jsp?id=<%=memberlist.get(i)%>"> <%=memberlist.get(i + 1)%></a></h3>
                        </td>
                    </tr>


                    <%
                                                                      i++;
                                                                  }


%>
 <tr>
                        <td bgcolor="#FAF3E4">

                            <h3> Arama Sayfası Bitmiştir, Şimdi Tüm Liste</h3>

                        </td>
                    </tr>
<%

 }


                                                              int sayac = 0;
                                                              while (sonucuser.next()) {
                                                                  if (sayac % 2 == 1) {
                                                                      sayac++;
                    %>
                    <tr>
                        <td bgcolor="#FAF3E4">

                            <h3> <a href="members.jsp?id=<%=sonucuser.getString("id")%>"> <%=sonucuser.getString("RealName")%></a></h3>

                        </td>
                    </tr>
                    <%} else {
                                        sayac++;                                        %>
                    <tr>
                        <td><h3>  <a href="members.jsp?id=<%=sonucuser.getString("id")%> "> <%=sonucuser.getString("RealName")%></a></h3>
                        </td>
                    </tr>

                    <%}
                                    }
                                %>
 </table>



<%




                                        }else{
                            ResultSet sonucuser = komut.executeQuery("SELECT * FROM UserTable WHERE id='" + id + "'");
                            while (sonucuser.next()) {
                                out.println("Gerçek isim = " + sonucuser.getString("RealName") + "<br>");
                                out.println("Kullanıcı Adı = " + sonucuser.getString("UserName"));
                                sonucuser.close();
                                //sql'deki email, einsah@hotmail.com;1 şeklinde olduğu için 1'i almak için alttaki 2 satırı yazdım.
                                ResultSet sonucprofil = komut2.executeQuery("SELECT * FROM profiltable WHERE id='" + id + "'");
                                out.println("test1");
                                String[] email = sonucprofil.getString("EMail_Show").split(";");
                                out.println("test2");

                                int showemail = Integer.parseInt(email[1]);
                                if (showemail == 1) {
                                    out.println("Email Adresi = " + email[0]);
                                } else {
                                    out.println("email adresi gizli");
                                }
                                String[] birtday = sonucprofil.getString("Birthday_Show").split(";");
                                int showbirtday = Integer.parseInt(birtday[1]);
                                if (showbirtday == 1) {
                                    out.println("Doğum Tarihi = " + birtday[0]);
                                } else {
                                    out.println("Doğum Tarihi gizli");
                                }

                                out.println("imzası" + sonucprofil.getString("Signature"));
                                if (user.GetAuthority() == 1) {
                                    out.println("tel no" + sonucprofil.getString("MobilePhone_Show").substring(0, sonucprofil.getString("MobilePhone_Show").length() - 2));
                                }
                            }

                        }
                    }catch(Exception e) {
                                        e.printStackTrace();


}%>
        </div>
    </div>
    <div>
        <div class="sidebar">
            <img src="images/title4.gif" alt="" width="238" height="21" />
            <div class="news">

                <span> <%=yazi.SonDuyuru1Baslik()%></span>
                <p><a href=" <%=yazi.SonDuyuru1Adres()%>   "> <%=yazi.SonDuyuru1()%></a></p>
            </div>
            <div class="news pad25">
                <span> <%=yazi.SonDuyuru2Baslik()%></span>
                <p><a href=" <%=yazi.SonDuyuru2Adres()%>   "> <%=yazi.SonDuyuru2()%></a></p>
            </div>
            <a href="duyuru.jsp"><img src="images/tumduyuru.png" alt=""  /></a>
        </div>
    </div>
    <div class="infoblock border">
        <img src="images/title5.gif" alt="" width="273" height="24" /><br />
        <a href="http://www.facebook.com/FUYazilimKulubu"><img border="0" src="images/facelogo.jpg" ></a>

        <p><a href="<%=yazi.Yazi3Link()%>"><%=yazi.Bilgi3()%></a></p>
        <a href="<%=yazi.Yazi3Link()%>"><img src="images/more_g.gif" alt="" width="76" height="28" /></a>
    </div>
    <div class="infoblock">
        <img src="images/title6.gif" alt="" width="281" height="24" /><br />
        <img src="images/calender.png" alt="" class="pic" />
        <p><a href="<%=yazi.Yazi4Link()%>"><%=yazi.Bilgi4()%></a></p>
        <a href="<%=yazi.Yazi4Link()%>"><img src="images/more_g.gif" alt="" width="76" height="28" /></a>	  </div>
</div>
<div id="footer">
    <center>	Fu Yazılım Kulübü &copy; 2011 &nbsp; &nbsp; <a href="" target="_blank">Web Design</a> by <a href="" target="_blank">FUYazılım Kulübü</a></center>	</div>
<map name="Map">
    <area shape="rect" coords="600,264,652,290" href="#">
</map>
</body>
</html>
